package icegps.com.pingdj.utils;


import android.content.Context;
import android.os.Handler;
import android.widget.Toast;

import icegps.com.pingdj.App;


/**
 * Created by 111 on 2017/11/21.
 */

public class Utils {
    private static Toast toast;
    private static Handler handler;
    private static  Context sContext;
    public static void init(Context context) {
        sContext=context;
        handler = new Handler();
    }

    public static void showToast(final String content) {
        post(new Runnable() {
            @Override
            public void run() {
                if (toast == null) {
                    toast = Toast.makeText(sContext, content, Toast.LENGTH_SHORT);
                } else {
                    toast.setText(content);
                }
                toast.show();
            }
        });

    }

    public static void post(Runnable runnable) {
        handler.post(runnable);
    }

    public static void postDelayed(Runnable runnable, int delayMillis) {
        handler.postDelayed(runnable, delayMillis);
    }

}